package com.qf.controller;

import com.qf.annotations.RequestMapping;
import com.qf.pojo.TbUser;
import com.qf.service.Impl.gouwucheserviceImpl;
import com.qf.service.gouwucheservice;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RequestMapping("/gouWuChe")
public class GouWuCheController {
    gouwucheservice gouwucheservice = new gouwucheserviceImpl();
    @RequestMapping("/deleteGouWu")
    public String gouwuche(HttpServletRequest request, HttpServletResponse response){
        Integer goodId = Integer.parseInt(request.getParameter("pid"));
//        TbUser loginUser = (TbUser) request.getSession().getAttribute("loginUser");
//        Integer num = Integer.parseInt(request.getParameter("num"));
//        long uid = loginUser.getId();

        gouwucheservice.deletegwc(goodId);
        return "redirect:/cart/show";
    }
    @RequestMapping("/clean")
    public String gouwu(HttpServletRequest request,HttpServletResponse response){
        TbUser loginUser = (TbUser) request.getSession().getAttribute("loginUser");
        long id = loginUser.getId();
        gouwucheservice.clean(id);

        return "redirect:/cart/show";
    }
}
